package com.geekca.d4;

import java.util.Arrays;

public class BubbleSort {
    public static void main(String[] args) {
        /**
         * 冒泡排序
         */
        int[] arr= {5,2,3,1,9,10,23,58,11};
        for (int i = 0; i < arr.length-1; i++) {
            int round = arr.length-1-i;
            System.out.println("第"+(i+1)+"轮" + "有"+round+"次交换操作");
            for (int j = 0; j <round ; j++) {
                System.out.println(arr[j]);
                System.out.println(arr[j+1]);
                if(arr[j]>arr[j+1]){
                    int tmp =arr[j+1];
                    arr[j+1]=arr[j];
                    arr[j]=tmp;
                }
            }
            
        }
        System.out.println(Arrays.toString(arr));
    }
}
